﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddCost.aspx.cs" Inherits="MemberMgr.Website.Product.AddCost" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script type="text/javascript">

        var searchKeyDown = function(sender, e) {
            if (e.getKey() == 13) {
                if (!Ext.isEmpty(sender.getValue())) {
                    X.SearchKeyPress();
                }
            }
        };
        
        var GetSum = function() {
            if(Ext.get('fpSearchProduct').getFrom().isValid())
            {
                var number = Ext.get('txtCostNum').getValue();
                var cut =  Ext.get('txtCostCut').getValue();
                var price = Ext.get('hdnPrice').getValue();
                
                console.log(number * cut * price);
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" Locale="zh-CN" />
    <ext:Viewport ID="Viewport1" runat="server" Layout="border">
        <Items>
            <ext:FormPanel ID="fpSearchPanel" runat="server" Region="North" Title="会员信息" Padding="5"
                Height="100" Frame="true" Margins="5 5 5 5" Icon="Magnifier" LabelWidth="80">
                <Items>
                    <ext:TriggerField ID="txtSearchNo" FieldLabel="会员编号" Margins="5 5 5 5" runat="server"
                        Width="200">
                        <Triggers>
                            <ext:FieldTrigger Icon="Clear" Qtip="清除查询结果" Tag="Del" />
                            <ext:FieldTrigger Icon="Search" Tag="Search" />
                        </Triggers>
                        <Listeners>
                            <KeyDown Fn="searchKeyDown" />
                        </Listeners>
                        <DirectEvents>
                            <TriggerClick OnEvent="btnSearchMember_Click" DisableCaching="true">
                                <EventMask ShowMask="true" Msg="正在查询，请稍后..." />
                                <ExtraParams>
                                    <ext:Parameter Name="Tag" Value="tag" Mode="Raw" />
                                </ExtraParams>
                            </TriggerClick>
                        </DirectEvents>
                    </ext:TriggerField>
                    <ext:Hidden ID="hdnMemberID" runat="server" />
                    <ext:Label ID="lblMemberInfo" FieldLabel="会员信息" runat="server" LabelSeparator=""
                        AutoWidth="true" />
                </Items>
            </ext:FormPanel>
            <ext:FormPanel ID="fpSearchProduct" runat="server" Region="Center" Title="商品信息" Padding="5"
                Frame="true" Margins="5 5 5 5" Icon="Magnifier" Height="100">
                <Items>
                    <ext:TriggerField ID="txtProductNo"  FieldLabel="商品编号" Margins="5 5 5 5" runat="server" Width="200">
                        <Triggers>
                            <ext:FieldTrigger Icon="Clear" Qtip="清除查询结果" Tag="Del" />
                            <ext:FieldTrigger Icon="Search" Tag="Search" />
                        </Triggers>
                       <Listeners>
                        <TriggerClick  Handler="if(index==0){#{fpSearchProduct}.reset()}else{#{winProductSearch}.show()}" />
                       </Listeners>
                    </ext:TriggerField>
                    <ext:Hidden ID="hdnProductID" runat="server" />
                    <ext:Hidden ID="hdnPrice" runat="server" Text="0"/>
                    <ext:Label ID="lblProductInfo" FieldLabel="商品信息" runat="server" LabelSeparator="" AutoWidth="true" />
                    <ext:NumberField ID="txtCostNum" runat="server" AllowBlank="false" FieldLabel="购买数量" MinValue="0" Number="1">
                        <Listeners>
                            <Change Fn="" />
                        </Listeners>
                    </ext:NumberField>
                    <ext:NumberField ID="txtCostCut" runat="server" AllowBlank="false" FieldLabel="折扣" Number="10" MinValue="0" MaxValue="10" MinText="折扣不能为0。" MaxText="折扣不能超过10。"/>
                    <ext:NumberField ID="txtSum" runat="server" AllowBlank="false" FieldLabel="总金额" MinValue="0" />
                    <ext:Button ID="btnCost" runat="server" Text="添加消费信息" Icon="MoneyYen">
                        <DirectEvents>
                            <Click OnEvent="btnCost_Click"  DisableCaching="true" Before="return #{fpSearchProduct}.getForm().isValid();">
                                <EventMask Target="Page" Msg="数据提交中..." ShowMask="true" />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:FormPanel>
        </Items>
    </ext:Viewport>
    <ext:Store ID="storeProduct" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="ID">
                <Fields>
                    <ext:RecordField Name="PRODUCTNAME" />
                    <ext:RecordField Name="PRODUCTTYPE" />
                    <ext:RecordField Name="MAKER" />
                    <ext:RecordField Name="PRICE" Type="Float" />
                    <ext:RecordField Name="COMMENT" />
                    <ext:RecordField Name="PRODUCTSUM" Type="Float" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Window ID="winProductSearch" runat="server" Icon="PageWhiteText" Title="商品查询" CloseAction="Hide"
        Frame="true" Modal="true" Hidden="true" Width="400" Height="400" Resizable="false"
        Layout="fit">
        <Items>
            <ext:GridPanel ID="gpProducts" runat="server" StoreID="storeProduct" Title="商品信息"
                AutoExpandColumn="Comment" Margins="0 5 5 5" Region="Center" Frame="true">
                <TopBar>
                    <ext:Toolbar ID="tbrTools" runat="server">
                        <Items>
                            <ext:TextField ID="txtSearchProductName" FieldLabel="商品名称" runat="server" />
                            <ext:Button ID="btnSearchWin" runat="server" Text="查询商品" Icon="DatabaseGo">
                                <DirectEvents>
                                    <Click OnEvent="btnSearchWin_Click">
                                        <EventMask ShowMask="true" Msg="数据查询中..." Target="CustomTarget" CustomTarget="#{gpProducts}" />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel ID="cmGrid" runat="server">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column Header="商品名称" Width="100" DataIndex="PRODUCTNAME">
                        </ext:Column>
                        <ext:Column Header="商品类型" Width="100" DataIndex="PRODUCTTYPE">
                        </ext:Column>
                        <ext:NumberColumn Header="价格" Width="50" DataIndex="PRICE">
                        </ext:NumberColumn>
                        <ext:NumberColumn Header="数量" Width="50" DataIndex="PRODUCTSUM">
                        </ext:NumberColumn>
                        <ext:Column ColumnID="Comment" Header="备注" Width="100" DataIndex="COMMENT">
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="rowSelModeNote" runat="server">
                    </ext:RowSelectionModel>
                </SelectionModel>
                <LoadMask ShowMask="true" />
                <DirectEvents>
                    <RowDblClick OnEvent="SelectedProduct">
                        <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{gpProducts}" Msg="数据加载中..." />
                        <ExtraParams>
                            <ext:Parameter Name="productid" Value="#{gpProducts}.getSelectionModel().getSelected().id"
                                Mode="Raw" />
                        </ExtraParams>
                    </RowDblClick>
                </DirectEvents>
            </ext:GridPanel>
        </Items>
        <Buttons>
            <ext:Button ID="btnClose" runat="server" Text=" 关 闭 " Icon="Decline" OnClientClick="#{winProductSearch}.hide()" />
        </Buttons>
    </ext:Window>
    </form>
</body>
</html>
